<script type="text/javascript" src="<?=base_url()?>resource/js/layer/layer.js"></script>
<script type="text/javascript" src="<?=base_url()?>resource/js/layer/extend/layer.ext.js"></script>
<script type="text/javascript">
    $(function(){
        trbgmoves('#d3dff2');
    })
    function shitss(id){
        var sid= $("#sid"+id).val();
        window.open('http://www.aliexpress.com/snapshot/'+sid+'.html');
    }
    function AddBrandModel(id,brand){
        $('#postFrom').attr('display','block');
        $('#productName').val($('#productName'+id).text());
        $('#model').val('');
        $('#id').val(id);
        if(brand) {
            $('#brand').val(brand);
            $('#brand').attr('readonly','');
        }else{
            $('#brand').removeAttr('readonly','');
            $('#brand').val('');
        }
        layer.open({
            type: 1,
            title:'产品信息',
            area: ['720px', '300px'], //宽高
            content: $('#postFrom')
        });
        //分开写是因为考虑到网络问题，优先把层弹出来 再读数据
        if(brand) {
            $.post("<?=blang_url('ajax/ajax/GetAliExpressModel')?>", {'brand': brand}, function (data) {
                var modelInfo = JSON.parse(data);
                $('#modelList').html(modelInfo.modelStr);
                $('#modelArray').text(modelInfo.modelArray);
            });
        }else{
            $('#modelList').html('');
            $('#modelArray').text('');
        }
    }
    function submitBrandModel(){
        var modelText = $('#modelArray').text();
        var brand = $('#brand').val();
        var brandRep = brand.replace(/ /gm, '');
        var model = $('#model').val();
        var modelRep = model.replace(/ /gm, '');
        if(brandRep==''){
            alert('品牌不能为空');
            return false;
        }
        if(modelRep==''){
            alert('型号不能为空');
            return false;
        }
        if(modelText) {
            var modelArray = modelText.split(',');
            var inArray = $.inArray(modelRep, modelArray);
            if (inArray >= 0) {
                alert('型号已存在');
                return false;
            }
        }
    }
</script>
<!--top结束-->
<div class="mian">
    <div class="mian1">
        <div class="mian2">
            <!--left start-->
            <?php $this->load->view('defaults/common/left');?>
            <!--left end-->

            <!--right start-->
            <div class="right">
                <!--breadcrumb start-->
                <div class="righta"><?=$msg?> </div>
                <!--breadcrumb end-->

                <!-- contents start -->
                <div id="contents">
                    <div class="ct_content">
                        <table class="tbwd800">
                            <tr>
                                <th><?=lang('smtddh')?></th>
                                <th><?=lang('smtspm')?></th>
                                <th><?=lang('smtwbjg')?></th>
                                <th><?=lang('smtddsj')?></th>
                                <th><?=lang('smtcz')?></th>
                            </tr>
                            <?php foreach($UnrecognizedList as $row){?>
                                <tr class="moves" style="color: <?=$row['is_count']==2?'#ff0000':'#0000ff'?>">
                                    <td><?=$row['orderId']?></td>
                                    <td id="productName<?=$row['orderId']?>"><?=$row['productName']?></td>
                                    <td><?=$row['serviceAmount']/100?></td>
                                    <td><?=$row['orderDate']?></td>
                                    <td>
                                        <a href="javascript:void(0)" onclick="AddBrandModel('<?=$row['orderId']?>','<?=$row['brandName']?>')">
                                            <?=$row['is_count']==2?lang('smttjpphxh'):lang('smttjxh')?>
                                        </a>
                                    </td>
                                </tr>
                            <?php }?>
                            <tr><td colspan="5" align="center"><?=$pageshow?></td></tr>
                        </table>
                    </div>
                </div>
                <!-- contents end -->
            </div>
            <!--right end-->
            <div class="clear"></div>
        </div>
    </div>
</div>
<div id="postFrom" style="display: none" class="ct_content">
    <form method="post" action="<?=blang_url('orders/AliExpress/AddBrandOrModel')?>">
        <table class="tbwd800" cellspacing="0" style="border-collapse: collapse;margin-top: 20px;margin-left: 40px;width: 640px;">
            <tr>
                <td>产品名称:</td>
                <td>
                    <textarea  id="productName" name="productName" style="width: 550px;margin-top: 10px;" ></textarea>
                    <input type="hidden" id="id" name="id">
                </td>
            </tr>
            <tr>
                <td>品牌:</td>
                <td><input type="text" id="brand" name="brand" size="40"></td>
            </tr>
            <tr>
                <td>型号:</td>
                <td>
                    <input type="text" id="model" name="model" size="40">
                </td>
            </tr>
            <tr align="center">
                <td colspan="2"><input type="submit" value=" 确 定 " onclick="return submitBrandModel()"></td>
            </tr>
        </table>
        <br>
        <span style="display: none" id="modelArray"></span>
        <span style="margin-left: 40px;" id="modelList">已存在型号：666666666</span>
    </form>
</div>
